﻿using Core.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Core.IRepository
{
    public interface IBaseRepository
    {
        #region 实体操作接口
       
        void Add<T>(T entity) where T : BaseModel;

        void Delete<T>(T entity) where T : BaseModel;
        void Delete<T>(Expression<Func<T,bool>> expression) where T : BaseModel;
        void Delete<T>(int key) where T : BaseModel, new();

        void Update<T>(T entity, params string[] updateFields) where T : BaseModel;


        bool Exists<T>(Expression<Func<T, bool>> expression) where T : BaseModel;


        T Find<T>(int key) where T : BaseModel;
        Task<T> FindAsync<T>(int key) where T : BaseModel;

        IQueryable<T> Find<T>() where T : BaseModel;
        IQueryable<T> Find<T>(Expression<Func<T, bool>> expression) where T : BaseModel;
        IQueryable<T> Find<T,TOrder>(Expression<Func<T, bool>> expression, Expression<Func<T, TOrder>> order, bool isAsc = true) where T : BaseModel;
        IQueryable<T> Find<T,TOrder>(int pageIndex, int pageSize, Expression<Func<T, bool>> expression , Expression<Func<T, TOrder>> order, out int count, bool isAsc=true) where T : BaseModel;
        #endregion
        #region 静态方法接口
        int ExecuteNonQuery(string sql, params System.Data.IDataParameter[] ps);
        object ExecuteScalar(string sql, params System.Data.IDataParameter[] ps);
        System.Data.DataTable ExecuteDataTable(string sql, params System.Data.IDataParameter[] ps);
        #endregion
    }
}
